<?php

namespace app\admin\controller\customer;

use app\admin\controller\Base;
use think\Db;

/**
 * 用户组管理
 * Class GroupController
 * @package app\admin\controller\auth
 */
class Tax extends Base
{

    public function index()
    {
        return view();
    }


    /*管理产品*/
    public function taxwork()
    {
        $post = $this->request->param();
        if ($this->request->isPost()) {

            if (DB::name('tax')->where('id', $post['id'])->update($post)) {
                $this->success('操作成功!');
            }
            $this->error('操作失败');

        } else {
            $info = DB::name('tax')->where('id', input('param.id'))->find();
            $status = config('param.tax_status');
            $info['c_time']=date('Y-m-d H:i:s', $info['c_time']);
            $this->assign('info', $info);
            $this->assign('status', $status);
            return view();
        }
    }

    public function lists()
    {
        $map = array();
        $data = array();
        $post = $this->request->param();
        $data['count'] = DB::view('tax', 'id,c_time,company,uid,inname,inmobile,address,price,info,status,tax_info')
            ->view('user', ['company'=>'user_company'], 'tax.uid=user.id')
            ->where($map)
            ->count();
        $data['data'] = DB::view('tax', 'id,c_time,company,uid,inname,inmobile,address,price,info,status,tax_info')
            ->view('user', ['company'=>'user_company'], 'tax.uid=user.id')

            ->where($map)
            // ->fetchSql(true)
            ->order('id desc')->page(input("param.page"), input('param.limit'))->select();
        $tax_status = config('param.tax_status');
        foreach ($data['data'] as &$info) {
            $info['c_time'] = date('Y-m-d  H:i:s', $info['c_time']);
            $info['status'] = $tax_status[$info['status']];
        }
        if ($data['count'] > 0 && $data['data']) {
            $data['msg'] = '获取成功';
        } else {
            $data['msg'] = '获取数据为空';
        }
        $data['code'] = 0;
        return json($data);
    }




}